package com.wash.shoes.handler;
import com.wash.shoes.context.DataPermissionContext;
import org.springframework.stereotype.Component;

/**
 * 用户数据权限处理器
 */
@Component
public class UserDataPermissionHandler implements DataPermissionHandler {

    @Override
    public String handle(DataPermissionContext.DataPermissionInfo dataPermissionInfo) {
        // 获取当前用户ID
        Long userId = 1l;

        String field = dataPermissionInfo.getField();
        String tableAlias = dataPermissionInfo.getTableAlias();

        // 构建字段名
        String fieldName = tableAlias.isEmpty() ? field : tableAlias + "." + field;

        // 返回用户数据权限SQL
        return fieldName + " = " + userId;
    }

    @Override
    public String getType() {
        return "user";
    }
}